<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login Administrator</title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
</head>

<body>


<?php
session_start();
include("../include/config.php");

?>

<div id="wapper">
	<div class="tcat"><p>Đăng nhập quản trị viên</p>
	</div>
	
	<div id="borderlogin">
	<?php 
			if(isset($_POST["login"])) //name cua nut submit (co the dat khac)
{
	$username= $_POST["username"];
	$password= $_POST["password"];
	$SQL="SELECT * FROM users WHERE username='$username'";
	$rs=mysql_query($SQL);
	if($rs){
			if(mysql_num_rows($rs)>0){
				$row=mysql_fetch_array($rs); // lay gia tri cua cot rs
				if($row["password"]==md5($password)){
					echo ("Dang nhap thanh cong");
						$_SESSION['is_login']=1;
						$_SESSION['is_admin']=0;
						header("location:admin.php"); 
				} else{
					echo ("Mật khẩu không đúng");
					  }
			} else {
					echo ("Không tồn tại thành viên này");
					}			
	}			
}
			?>
		<div id="login">
		<form name="login" method="post" action="">
			<div id="taikhoan2">
			
			
			
							<div class="taikhoan">
								<p>Username:</p>
								<p>Password:</p>
								</div>
							<div class="taikhoan">
								<input name="username" type="text" id="username" value="" />
								<input name="password" type="password" id="password" value="" />
							</div>
	
			
			</div>
						<div class="bam">	
						<input type="submit" name="login" value="Login" />
									
						</div>
						</form>
		</div>
		
		
		<div id="copyright">
			<?php
				echo "$TITLE<br/>";
				echo "$ADDRESS<br/>";
			
			
			?>
		</div>	
		
	</div>
	
	
</div>
</body>
</html>
